package com.gopay.common.trace.httpclient;

import com.gopay.common.trace.def.Span;
import com.gopay.common.trace.def.Tracer;
import com.gopay.common.trace.enums.TraceType;
import com.gopay.common.trace.helper.LogAbstractHelper;
import com.gopay.common.trace.helper.LogHttpClientHelper;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.protocol.HttpContext;

import java.io.IOException;
import java.util.Date;

/**
 * httpClient  请求拦截器
 * @author ddh02
 * @HttpRequestInterceptorImpl
 * @2017/5/12 15:52  www.gopay.com.cn Inc.All rights reserved.
 */

public class HttpRequestInterceptorImpl extends HttpInterceptorBase
        implements HttpRequestInterceptor {

    private String url;

    public HttpRequestInterceptorImpl(String url) {
        this.url = url;
    }


    @Override
    public void process(HttpRequest httpRequest, HttpContext httpContext) throws HttpException, IOException {

        LogAbstractHelper helper = new LogHttpClientHelper();

        helper.beforeT(httpRequest, httpContext, url);

        httpContext.setAttribute(HELPER_TAG, helper);

    }
}
